package test2;

import java.util.*;

public class Main2 {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int a = input.nextInt();
        int b = input.nextInt();
        Map<Integer, Integer> map1 = new HashMap<>();
        int res = 0;
        for (int i = 0; i < a; i++)
            map1.put(input.nextInt(), input.nextInt());
        for (int i = 0; i < b; i++) {
            int key = input.nextInt();
            int value = input.nextInt();
            if (map1.containsKey(key))
                res += value * map1.get(key);
        }
        System.out.println(res);
    }
}
